
Instructions for replicating analyses presented in Liao, Steven, 
Neil Malhotra, and Benjamin J. Newman. Forthcoming. "Local Economic 
Benefits Increase Positivity toward Foreigners." Nature Human Behaviour.


######################################################################
*** I. Install Dependencies *** 
######################################################################

Replication created using R (version 3.6.1). Please install the following 
R packages used in the analyses.

- gridExtra: version = 2.3

- lfe: version = 2.8-3

- lme4: version = 1.1-21

- lmtest: version = 0.9-37

- multcomp: version = 1.4-10

- plm: version = 2.2-0

- RColorBrewer: version = 1.1-2

- rms: version = 5.1-3.1

- stargazer: version = 5.2.2 

- tidyverse: version = 1.2.1

- tools: version = 3.6.1


######################################################################
*** II. Datasets ***
######################################################################

The following files are datasets used in the analyses. 
Please make sure to download all files in their original format.

- cces-merge-rep.RData
  Cooperative Congressional Election Study (CCES) 2010, 2012, and 2014 
  panel data (https://cces.gov.harvard.edu/) merged with ZIP-code 
  measures of: 
  (1) Chinese FREI exposure (https://www.stevenliao.org/uploads/2/5/6/9/25699716/frei-elections.pdf)
  (2) Home prices (Zillow, https://www.zillow.com/research/data/)
  (3) Local characteristics from the U.S. Census Bureau's American 
  Community Survey (https://www.census.gov/programs-surveys/acs) and 
  ZIP Code Business Statistics (https://www.census.gov/data/developers/data-sets/cbp-nonemp-zbp/zbp-api.html). 
  
  Note: ZIP-code data on new vehicle registrations are excluded from this
  replication dataset due to the authors' data non-disclosure agreement with 
  Hedges & Company (https://hedgescompany.com/).
  
- pew-merge.RData
  Pooled cross-sectional data from the Pew Research Center 
  (https://www.pewresearch.org/download-datasets/):
  (1) The 2008 September Political/Foreign Policy Survey
  (2) The 2009 June Political Survey
  (3) The 2009 November "America's Place in the World" Survey
  (4) The 2012 U.S.-China Security Perceptions Project Survey
  (5) The 2013 November "America's Place in the World"" Survey
  (6) The 2014 August Political Survey
  (7) The 2015 December Political Survey
  
  The data above are merged with ZIP-code measures of:
  (1) Chinese FREI exposure (https://www.stevenliao.org/uploads/2/5/6/9/25699716/frei-elections.pdf)
  (2) Home prices (Zillow, https://www.zillow.com/research/data/)
  (3) Local characteristics from the U.S. Census Bureau's American 
  Community Survey (https://www.census.gov/programs-surveys/acs) 
  
- price-merge.RData
  ZIP-code level data on home prices from Zillow (https://www.zillow.com/research/data/) 
  merged with measures of:
  (1) Chinese FREI exposure (https://www.stevenliao.org/uploads/2/5/6/9/25699716/frei-elections.pdf)
  (2) Local characteristics from the U.S. Census Bureau's American 
  Community Survey (https://www.census.gov/programs-surveys/acs) 

- cmps-merge.RData
  2008 and 2012 cross-sectional survey data from the Collaborative Multiracial Post-Election 
  Surveys (CMPS, https://cmpsurvey.org/) merged with ZIP-code measures of:
  (1) Chinese FREI exposure (https://www.stevenliao.org/uploads/2/5/6/9/25699716/frei-elections.pdf)
  (2) Local characteristics from the U.S. Census Bureau's American 
  Community Survey (https://www.census.gov/programs-surveys/acs) 

- foia-aggregate.RData
  Aggregated Freedom of Information Act (FOIA) data on international students 
  in the United States by origin country, level of education, and year. 
  Figure-S1.R creates Figure S1 using the data.
  
- nar-df.Rdata
  Data on foreign acquisitions of U.S. residential real estate between 2010 
  and 2015 from the National Association of Realtors (NAR, 
  https://www.nar.realtor/sites/default/files/reports/2016/2016-profile-of-international-home-buying-activity-06-06-2016.pdf).

- did-vehicle.RData
  Given the authors' data non-disclosure agreement on new vehicle 
  registrations, this file contains difference-in-differences regression 
  results analyzed and saved by the authors for producing Table S11. 
  

######################################################################
*** III. R codes for the Analyses ***
######################################################################

The R scripts below will reproduce all the figures and tables in the 
manuscript and Supporting Information. Please set the working directory 
to where this instruction file is located by changing MAIN_DIR in each 
R script.

1) cces-analysis.R creates Figure 1 (left panel), Figure 2, and Tables S4-S11
2) pew-analysis.R creates Figure 1 (right panel), Figure 3, and Tables S12-S14
3) price-analysis.R creates Figure 4 and Table S1
4) cmps-analysis.R creates Tables S2-S3
5) Figure-S1.R creates Figure S1

